package cn.itcast.service.impl;

import cn.itcast.dao.AreaRepository;
import cn.itcast.domain.base.Area;
import cn.itcast.service.AreaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class AreaServiceImpl implements AreaService {
    @Autowired
    private AreaRepository areaRepository;

    @Override
    @Transactional
    public void saveBatch(List<Area> areas) {
       areaRepository.save(areas);//一次性保存list集合中所有对象
    }

    @Override
    public Page<Area> findPageDate(Specification<Area> specification, Pageable pageable) {
        //条件查询
        return areaRepository.findAll(specification,pageable);
    }
}
